from Assert.base_assert import baseAssert


class ProductAssert(baseAssert):
    def goodsList_query_assert(self,respose_json,code):
        #base层
        self.code_assert(code)

        #业务层，断言goodList（[]列表）
        #断言goodList，1.存在
        # 这里.get字典的一个方法,没取到返回None，[""]这种取法没有会报错的
        self.type_have_assert("goodList",respose_json.get("goodList"))

    def productDetail_assert(self,respose_json,code):
        #base层
        self.code_assert(code)
        #业务层，断言item
        #1.断言item存在，2.断言item不为空
        self.type_have_assert("item",respose_json.get("item"))
        self.type_notnull_assert("item",respose_json.get("item"))

    def placeAnOrder_assert(self,respose_json,code):
        #base层
        self.code_assert(code)

        #业务层，1.crateTime，2.OrderNumber3.userId
        #1.断言crateTime，1.存在，2.不为空
        self.type_have_assert(respose_json.get("crateTime"),"crateTime")
        self.type_notnull_assert(respose_json.get("crateTime"),"crateTime")
        #2.断言OrderNumber，1.存在，2.不为空
        self.type_have_assert(respose_json.get("orderNumber"),"orderNumber")
        self.type_notnull_assert(respose_json.get("orderNumber"),"orderNumber")
        #3.userId，1.存在，2.不为空
        self.type_have_assert(respose_json.get("userId"),"userId")
        self.type_notnull_assert(respose_json.get("userId"),"userId")

    def orderPay_assert(self,respose_json,code):
        #base层
        self.code_assert(code)

        #业务层 1.crateTime,2.translate_language
        #1.crateTime 1.存在 2.不为空
        self.type_have_assert(respose_json.get("crateTime"),"crateTime")
        self.type_notnull_assert(respose_json.get("crateTime"),"crateTime")
        #2.translate_language 1.存在 2.类型为string 3.不为空 4.内容等于zh-CN
        self.type_have_assert(respose_json.get("translate_language"),"translate_language")
        self.type_notnull_assert(respose_json.get("translate_language"), "translate_language")
        self.type_assert("translate_language",respose_json.get("translate_language"),str)
        self.value_assert("translate_language",respose_json.get("translate_language"),"zh-CN")

    def shoppingJoinCart_assert(self,respose_json,code):
        #base层
        self.code_assert(code)

        #业务层 1.createTime 2.translate_language 3.userId 4.cartList
        #crateTime 1.存在 2.不为空 3.类型str
        self.type_have_assert(respose_json.get("createTime"),"createTime")
        self.type_notnull_assert(respose_json.get("createTime"),"createTime")
        self.type_assert("createTime",respose_json.get("createTime"),str)
        #translate_language 1.存在 2.不为空 3.类型str 4.值为zh-CN
        self.type_have_assert(respose_json.get("translate_language"),"translate_language")
        self.type_notnull_assert(respose_json.get("translate_language"), "translate_language")
        self.type_assert("translate_language",respose_json.get("translate_language"),str)
        self.value_assert("translate_language",respose_json.get("translate_language"),"zh-CN")
        #userId 1.存在 2.不为空 3.类型str
        self.type_have_assert(respose_json.get("userId"),"userId")
        self.type_notnull_assert(respose_json.get("userId"),"userId")
        self.type_assert("userId",respose_json.get("userId"),str)
        #cartList 1.存在 2.类型List
        self.type_have_assert(respose_json.get("cartList"),"cartList")
        self.type_assert("cartList",respose_json.get("cartList"),list)

    def delCart_assert(self,respose_json,code):
        #base层
        self.code_assert(code)

        #业务层断言 1.createTime 2.translate_language
        #crateTime 1.存在 2.不为空 3.类型str
        self.type_have_assert(respose_json.get("createTime"),"createTime")
        self.type_notnull_assert(respose_json.get("createTime"),"createTime")
        self.type_assert("createTime",respose_json.get("createTime"),str)
        #translate_language 1.存在 2.不为空 3.类型str 4.值为zh-CN
        self.type_have_assert(respose_json.get("translate_language"),"translate_language")
        self.type_notnull_assert(respose_json.get("translate_language"), "translate_language")
        self.type_assert("translate_language",respose_json.get("translate_language"),str)
        self.value_assert("translate_language",respose_json.get("translate_language"),"zh-CN")

    def checkOrderStatus_assert(self,respose_json,code):
        #base层
        self.code_assert(code)

        #业务层 1.queryTime 2.translate_language
        #crateTime 1.存在 2.不为空 3.类型str
        self.type_have_assert(respose_json.get("queryTime"),"queryTime")
        self.type_notnull_assert(respose_json.get("queryTime"),"queryTime")
        self.type_assert("queryTime",respose_json.get("queryTime"),str)

        #translate_language 1.存在 2.不为空 3.类型str 4.值为zh-CN
        self.type_have_assert(respose_json.get("translate_language"),"translate_language")
        self.type_notnull_assert(respose_json.get("translate_language"), "translate_language")
        self.type_assert("translate_language",respose_json.get("translate_language"),str)
        self.value_assert("translate_language",respose_json.get("translate_language"),"zh-CN")

    def checkLogisticsStatus_assert(self, respose_json, code):
        # base层
        self.code_assert(code)

        # 业务层 1.queryTime 2.translate_language
        # crateTime 1.存在 2.不为空 3.类型str
        self.type_have_assert(respose_json.get("queryTime"), "queryTime")
        self.type_notnull_assert(respose_json.get("queryTime"), "queryTime")
        self.type_assert("queryTime", respose_json.get("queryTime"), str)

        # translate_language 1.存在 2.不为空 3.类型str 4.值为zh-CN
        self.type_have_assert(respose_json.get("translate_language"), "translate_language")
        self.type_notnull_assert(respose_json.get("translate_language"), "translate_language")
        self.type_assert("translate_language", respose_json.get("translate_language"), str)
        self.value_assert("translate_language", respose_json.get("translate_language"), "zh-CN")

    def shoppingInventory_assert(self, respose_json, code):
        # base层
        self.code_assert(code)

        # 业务层断言 1.createTime 2.translate_language
        # crateTime 1.存在 2.不为空 3.类型str
        self.type_have_assert(respose_json.get("createTime"), "createTime")
        self.type_notnull_assert(respose_json.get("createTime"), "createTime")
        self.type_assert("createTime", respose_json.get("createTime"), str)
        # translate_language 1.存在 2.不为空 3.类型str 4.值为zh-CN
        self.type_have_assert(respose_json.get("translate_language"), "translate_language")
        self.type_notnull_assert(respose_json.get("translate_language"), "translate_language")
        self.type_assert("translate_language", respose_json.get("translate_language"), str)
        self.value_assert("translate_language", respose_json.get("translate_language"), "zh-CN")


